package com.twu.biblioteca;

import java.io.BufferedReader;

/**
 * Created by abhishekpuri on 10/6/14.
 */
public class Menu {


    private IOHandler ioHandler;
    private final int numberOfOptions=4;

    public Menu() {
        ioHandler=new IOHandler();
    }

    public Menu(BufferedReader inStream) {
        ioHandler=new IOHandler(inStream);
    }
    public void showMenuOptions() {
        ioHandler.printlnToConsole("Choose the desired option");
        ioHandler.printlnToConsole("1. List Books");
        ioHandler.printlnToConsole("2. Checkout Book");
        ioHandler.printlnToConsole("3. Return Book");
        ioHandler.printlnToConsole("4. Quit");
    }

    public int readUserInput() {
        ioHandler.printToConsole("Enter the choice : ");
        Integer choice= ioHandler.readInt();
        if(choice == null || choice > numberOfOptions){
            ioHandler.printlnToConsole("Select a valid option!");
            return -1;
        }
        return choice;
    }

//    public void chooseMenuOption(int optionNumber){
//        if(numberOfOptions<optionNumber) {
//            ioHandler.printlnToConsole("Select a valid option!");
//        }
//        else {
//
//        }
//
//    }
}
